package com.gf.service.impl;

import com.gf.bean.Shop;
import com.gf.dao.ShopMapper;
import com.gf.dao.UserMapper;
import com.gf.service.ShopService;
import com.gf.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class ShopServiceImpl  implements ShopService {


    @Override
    public List<Shop> selectAll() {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        List<Shop> shops = sqlSession.getMapper(ShopMapper.class).selectAll();
        MybatisUtils.closesqlSession(sqlSession);
        return shops;
    }

    @Override
    public Shop selectByUsername(String shopname) {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        Shop selectshopname = sqlSession.getMapper(ShopMapper.class).selectshopname(shopname);
        MybatisUtils.closesqlSession(sqlSession);
        return selectshopname;
    }

    @Override
    public int insert(Shop record) {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        int flag= sqlSession.getMapper(ShopMapper.class).insert(record);
        MybatisUtils.closesqlSession(sqlSession);
        return flag;
    }

    @Override
    public List<Shop> selectsthreeshopbysocre() {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        List<Shop> shops = sqlSession.getMapper(ShopMapper.class).selectsthreeshopbysocre();
        MybatisUtils.closesqlSession(sqlSession);
        return shops;

    }

    @Override
    public Shop selectByPrimaryKey(int shop_id) {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        Shop shop = sqlSession.getMapper(ShopMapper.class).selectByPrimaryKey(shop_id);
        MybatisUtils.closesqlSession(sqlSession);
        return shop;
    }

    @Override
    public Shop selectshopname(String shop_name) {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        Shop shop = sqlSession.getMapper(ShopMapper.class).selectshopname(shop_name);
        MybatisUtils.closesqlSession(sqlSession);
        return shop;
    }
}
